<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div id="div">我是div</div>
<!--<script>-->
<!--    window.id = 'window'-->
<!--    document.getElementById('div').onclick = function () {-->
<!--        alert(this.id)-->

<!--        var callback = function () {-->
<!--            alert(this.id)-->
<!--        }-->
<!--        callback.apply(this)-->
<!--    }-->
<!--</script>-->
<script>
    window.id = 'window'
    document.getElementById('div').onclick = function () {
        alert(this.id)
        var that = this
        var callback = function () {
            alert(that.id)
        }
        callback()
    }
</script>
</body>
</html>
